<?php
    use yii\helpers\Html;
    use backend\utils\ImageSize;
    use yii\helpers\Url;
    use yii\widgets\ActiveForm;
?>
<style type="text/css">
    .has-success .text-danger{color: #1ab394;}
    .ajaxUpload{border:1px dashed #666;width: 100px;height:100px;background-color: #d6d6d6;border-radius: 4px;cursor: pointer;line-height: 100px;text-align: center;background-size: cover;}
    .ajaxUpload:hover{border-color: #333}
    .upload_progress{height:5px;width:100px;margin-top: 5px;display:none;}
</style>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">

            <div class="ibox">
                <div class="ibox-title">
                    <h5><?=Html::a('<i class="fa fa-angle-left"></i> 返回','javascript:history.go(-1);',['class'=>'btn btn-xs btn-white'])?> 编辑首页轮播图</h5>
                </div>
                <div class="ibox-content">
                    <?= Html::beginForm('','post',['id' => 'login-form','class' => 'form-horizontal m-t pass-form'])?>
                        <?=Html::activeInput('hidden',$model, 'id') ?>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>标题：</label>
                            <div class="col-sm-4">
                                <?=Html::activeInput('text',$model, 'title',['class'=>'form-control']) ?>
                                <?=Html::error($model,'title',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>移动端图片：</label>
                            <div class="col-sm-5">
                                <div class="ajaxUpload" id="upload_image" style="width: 216px;height:80px;background:url('<?=ImageSize::image(['url'=>$model->image,'width'=>216,'high'=>80])?>')">
                                    点击上传图片
                                </div>
                                只能上传jpg jpeg png格式,宽高比例 1080*400
                                <div class="progress upload_progress">
                                    <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                        <span class="sr-only"></span>
                                    </div>
                                </div>
                                <?=Html::activeInput('hidden',$model, 'image',['class'=>'form-control','id'=>'upload_image_input']) ?>
                                <?=Html::error($model,'image',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>PC端图片：</label>
                            <div class="col-sm-5">
                                <div class="ajaxUpload" id="upload_image2" style="width: 384px;height:80px;background:url('<?=ImageSize::image(['url'=>$model->pc_image,'width'=>384,'high'=>80])?>')">
                                    点击上传图片
                                </div>
                                只能上传jpg jpeg png格式,宽高比例 1920*400
                                <div class="progress upload_progress">
                                    <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                        <span class="sr-only"></span>
                                    </div>
                                </div>
                                <?=Html::activeInput('hidden',$model, 'pc_image',['class'=>'form-control','id'=>'upload_image_input2']) ?>
                                <?=Html::error($model,'pc_image',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">url：</label>
                            <div class="col-sm-4">
                                <?=Html::activeInput('text',$model, 'url',['class'=>'form-control','value'=>$model->url?:'http://']) ?>
                                <?=Html::error($model,'url',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">移动端url：</label>
                            <div class="col-sm-4">
                                <?=Html::activeInput('text',$model, 'app_url',['class'=>'form-control','value'=>$model->app_url?:'http://']) ?>
                                <?=Html::error($model,'app_url',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>排序：</label>
                            <div class="col-sm-1">
                                <?=Html::activeInput('text',$model, 'sort',['class'=>'form-control']) ?>
                                <?=Html::error($model,'sort',['class'=>'input_err'])?>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <?=Html::submitButton('保存',['class'=>'btn btn-primary col-md-offset-2'])?>
                                <?=Html::a('返回','javascript:history.go(-1);',['class'=>'btn btn-white'])?>
                            </div>
                        </div>
                    <?=Html::endForm() ?>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="/js/plugins/plupload-2.1.2/plupload.full.min.js"></script>
    <script type="text/javascript" src="/js/plugins/plupload-2.1.2/oss_upload.js" ></script>
    <script>
        var ossUpload = <?=$ossUpload?>;
        $(function(){
            get_area(0,$('.select_area:eq(0) .province'));
            upload_image({
                'browse_button':'upload_image',
            },function(up, file, info){
                $('#upload_image').css({'background':'url("<?=ImageSize::get_base_url()?>'+image_resize({'url':g_object_name,'width':216,'high':80})+'")'});
                $('#upload_image_input').val(g_object_name);
            });
            upload_image({
                'browse_button':'upload_image2'
            },function(up, file, info){
                $('#upload_image2').css({'background':'url("<?=ImageSize::get_base_url()?>'+image_resize({'url':g_object_name,'width':384,'high':80})+'")'});
                $('#upload_image_input2').val(g_object_name);
            });
        });
    </script>